using System;
using System.Text;

namespace zTalk.Network
{
    public class Packet
    {
        public const int HEADER_LENGTH = 5;

        public Opcodes Opcode = Opcodes.NONE;
        public int Length = 0;
        public byte[] Data;

        public static Packet Create(Opcodes opcode, String data)
        {
            Packet packet = new Packet();
            packet.Opcode = opcode;
            byte[] bytes = Encoding.UTF8.GetBytes(data);

            packet.Length = bytes.Length;
            packet.Data = bytes;

            return packet;
        }
    }
}
